package com.xxd.spring.boot.demo.zhuhongbing.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.zhuhongbing.util.Result;
import com.xxd.spring.boot.demo.zhuhongbing.entity.Student;
import com.xxd.spring.boot.demo.zhuhongbing.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentMapper studentMapper;

    @RequestMapping(value="/listStudent")
    public Result Student(Page page, @RequestParam Map<String,Object> paramsMap){
        IPage resPage=studentMapper.listPage(page,paramsMap);
        return new Result().setData(resPage);
    }



    @RequestMapping(value="/insertStudent")
    public Result InsertStudent(@RequestBody Student student){
        studentMapper.insert(student);
        return new Result().success();
    }

    @RequestMapping(value="/updateStudent")
    public Result updateStudent(@RequestBody Student student){
        studentMapper.MyUpdateById(student);
        return new Result().success();
    }

    @RequestMapping(value="/delStudent/{id}")
    public Result delStudent(@PathVariable("id") Integer id){
        studentMapper.deleteById(id);
        return new Result().success();
    }
}
